templateViewInit = ()=>{

    searchFormInfo();

    // 已知数据渲染
    var inst = table.render({
        elem: '#notice-list',
        id:'notice-list-id',
        height: '#content-body-210',
        // url: top.tools.getBaseUrl()+'/user/getPage',
        method: 'post',
        headers:{
            'Access-Token':top.tools.cookie.token(),
            'Content-Type':'application/json',
        },
        toolbar: '#noticeToolbar',
        defaultToolbar: ['filter', 'exports', 'print', { // 右上角工具图标
            title: '提示',
            layEvent: 'LAYTABLE_TIPS',
            icon: 'layui-icon-tips',
            onClick: function (obj) { // 2.9.12+
                layer.alert('自定义工具栏图标按钮');
            }
        }],
        cols: [
            [
                {type: 'checkbox', width: 50},
                {field: 'id', title: 'ID', width: 80},
                {field: 'title', title: '公告标题', minWidth: 200},
                {field: 'type', title: '类型', width: 100 ,align: 'center',templet:function (d){
                    return  top.tools.dict().getDictLabel('system_notice_type',d.type);
                }},
                {field: 'status', title: '发布状态', width: 100,align: 'center', templet: function(d){
                        return  top.tools.dict().getDictLabel('system_notice_status',d.status);
                    }},
                {field: 'creator', title: '发布人', width: 120},
                {field: 'createTime', title: '发布时间', width: 180,align: 'center',templet:function (d) {
                        return top.tools.form.formatDate(d.createTime);
                    }},
                {fixed: 'right', title: '操作', align: 'center',  width: 230, toolbar: '#barDemo'}
            ]
        ],
        data:[{type:1,status:1}],
        parseData: dataToFormat,
        //skin: 'line', // 表格风格
        //even: true,
        page: true, // 是否显示分页
        limits: [15, 20, 30,50],
        limit: 15, // 每页默认显示的数量
        done: function (res, curr, count) {
            $(".layui-table th[data-field=" + 0 + "] .layui-table-cell").html("");
        }
    });

    // 工具栏事件
    table.on('toolbar(notice-list)', function (obj) {
        var id = obj.config.id;
        var checkRow = table.checkStatus(id);

        var data = checkRow.data;
        if (obj.event === 'add') {
            openForm({
                title:"新增用户",
                btn:1,
                save:(closeid)=>{
                    formFun.save(inst,closeid)
                },
                reset:(closeid)=>{
                    form.val('notice_form', top.tools.form.getFindElementOnObj("#lay-notice-form",false));
                },
                before:(index,layero,that,isEdit)=>{
                    workdbFieldConvert(document.querySelectorAll('#lay-notice-form .dict-module'),isEdit);
                    form.val('notice_form', {
                        sort:inst.config.page.count+1,
                        status:true
                    });
                },
                area:'40%'
            },'notice_form')
        } else if (obj.event === 'update') {
            if (checkRow.data.length<=0){
                layer.msg("请选择数据！");
                return
            }
            openForm({
                title:"查看用户",
                btn:-1,
                area:'40%',
                before:(index,layero,that,isEdit)=>{
                    workdbFieldConvert(document.querySelectorAll('#lay-notice-form .dict-module'),isEdit);
                    form.val('notice_form', data);
                }
            },'notice_form')
        } else  if (obj.event === 'del') {
            if (checkRow.data.length<=0){
                layer.msg("请选择数据！");
                return
            }
            let ids = data.map((user) => user.id);
            openConfirm(()=>{
                formFun.remove({
                    id:ids.join(',')
                },inst)
            });
        }
    });
// 触发单元格工具事件
    table.on('tool(notice-list)', function (obj) { // 双击 toolDouble
        var data = obj.data; // 获得当前行数据
        if (obj.event === 'edit') {
            openForm({
                title:"编辑用户",
                btn:1,
                save:(closeid)=>{
                    formFun.save(inst,closeid)
                },
                reset:(closeid)=>{
                    form.val('notice_form', top.tools.form.getFindElementOnObj("#lay-notice-form",false));
                },
                area:'40%',
                before:(index,layero,that,isEdit)=>{
                    workdbFieldConvert(document.querySelectorAll('#lay-notice-form .dict-module'),isEdit);
                    formFun.setValue(data,'notice_form')
                }
            },'notice_form')
        } else if (obj.event === 'view') {
            openForm({
                title:"查看资源",
                btn:-1,
                area:'40%',
                before:(index,layero,that,isEdit)=>{
                    workdbFieldConvert(document.querySelectorAll('#lay-notice-form .dict-module'),isEdit);
                    formFun.setValue(data,'notice_form')
                }
            },'notice_form')
        } else if (obj.event === 'del') {
            openConfirm(()=>{
                formFun.remove(data,inst)
            });
        }
    });
    queryButton('notice-list-id');
    formReset();
    // 状态 - 开关操作
    form.on('switch(notice-status)', function(obj){
        let data = {
            id:$(obj.elem).attr("id"),
            status:obj.elem.checked? 1:0
        }
        top.API.user().save(data,()=>{
            table.reloadData('notice-list-id', {
                where: {}, // 数据异步请求时携带的字段集 --- 属性设置有效，因属于数据相关属性
                scrollPos: true, // 设定重载数据或切换分页时的滚动条的位置状态 --- 属性设置有效
                page: {
                    curr: inst.config.page.curr,
                    limit: inst.config.page.limit
                }
            });
        })
    });
}

var formFun = {

    save:(userTable,closeid)=>{
        let formData = top.tools.form.getFindElementOnObj("#lay-user-form",true);
        if (typeof formData === 'boolean'){
            return;
        }
        if (formData.status && formData.status === 'on' ){
            formData.status = 1;
        }else {
            formData.status = 0;
        }

        top.API.user().save(formData,(res)=>{
            layer.msg(res.message, {icon: 1}, function(){
                // layer.msg('提示框关闭后的回调');
                if (userTable){
                    table.reloadData('user-list-id', {
                        scrollPos: true, // 设定重载数据或切换分页时的滚动条的位置状态 --- 属性设置有效
                        page: {
                            curr: userTable.config.page.curr,
                            limit: userTable.config.page.limit
                        }
                    });
                }
                if (closeid){
                    layer.close(closeid);
                }
            });
        })
    },
    remove:(data,userTable)=>{
        top.API.user().delUser(data,(res)=>{
            layer.msg(res.message, {icon: 1}, function(){
                // layer.msg('提示框关闭后的回调');
                if (userTable){
                    table.reloadData('user-list-id', {
                        scrollPos: true, // 设定重载数据或切换分页时的滚动条的位置状态 --- 属性设置有效
                        page: {
                            curr: userTable.config.page.curr,
                            limit: userTable.config.page.limit
                        }
                    });
                }
            });
        })
    },
    setValue:(data,eleId)=>{
        data.status = parseInt(data.status);
        form.val(eleId, data);
    }
}


